package com.czc.demo.controller;


import com.czc.demo.model.User;
import com.czc.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getOneUser")
    public User getOneUser(@RequestParam(value = "id") Long id) {
        User user = new User();
        user.setFirstName("asd");
        user.setLastName("czc");
        return user;
    }

    @RequestMapping("/users")
    public List<User> users(@PageableDefault() Pageable pageable) {
        return userService.getAll(pageable).getContent();
    }


}
